home *** CD-ROM | disk | FTP | other *** search
/ Champak 141 / (Vol 141) Oct 17 2011.iso / Games / gamma-bros.swf / scripts / __Packages / classes / shots / BlasterALaser.as next >
Encoding:
Text File  |  2011-10-17  |  2.8 KB  |  82 lines

  1. class classes.shots.BlasterALaser
  2. {
  3.    var id;
  4.    var x;
  5.    var y;
  6.    var dir;
  7.    var color;
  8.    var xInc;
  9.    var l;
  10.    var clip;
  11.    var startClip;
  12.    var endClip;
  13.    var power = 40;
  14.    var c = 1;
  15.    var endMessageSent = false;
  16.    var x2 = 0;
  17.    var Name = "blasterALaser";
  18.    function BlasterALaser(px, py, pcolor, pdir, pid)
  19.    {
  20.       this.id = pid;
  21.       this.x = px;
  22.       this.y = py;
  23.       this.dir = pdir;
  24.       this.color = pcolor;
  25.       this.xInc = this.dir != "L" ? 15 : -15;
  26.       this.l = _root.randRange(20,40);
  27.       _root.d = _root.d + 1;
  28.       this.clip = _root.createEmptyMovieClip("blasterALaser" + this.id + "Clip",_root.d);
  29.       this.clip._x = this.x;
  30.       this.clip._y = this.y;
  31.       _root.d = _root.d + 1;
  32.       this.startClip = this.clip.attachMovie("blasterALaserSeg","blasterALaserSegBlastClip" + this.id,_root.d);
  33.       this.startClip.gotoAndStop(this.color + this.dir);
  34.       this.startClip.segment.gotoAndStop("blast");
  35.       this.x2 += this.xInc;
  36.       _root.d = _root.d + 1;
  37.       this.endClip = this.clip.attachMovie("blasterALaserSeg","blasterALaserSegEndCapClip" + this.id,_root.d);
  38.       this.endClip._x = this.x2;
  39.       this.endClip.gotoAndStop(this.color + this.dir);
  40.       this.endClip.segment.gotoAndStop("startCap");
  41.    }
  42.    function main()
  43.    {
  44.       this.c = this.c + 1;
  45.       if(this.x + (this.c - 1) * this.xInc < 1150 && this.x + (this.c - 1) * this.xInc > -150)
  46.       {
  47.          _root.d = _root.d + 1;
  48.          var _loc3_ = this.clip.attachMovie("blasterALaserSeg","blasterALaserSeg" + this.c + "Clip" + this.id,_root.d);
  49.          _loc3_.gotoAndStop(this.color + this.dir);
  50.          _loc3_.segment.gotoAndStop("mid");
  51.          _loc3_._x = this.x2;
  52.          this.xInc = this.dir != "L" ? 100 : -100;
  53.          this.x2 += this.xInc;
  54.          this.endClip._x += this.xInc;
  55.       }
  56.       if(this.c > this.l)
  57.       {
  58.          if(!this.endMessageSent)
  59.          {
  60.             _root["blasterA" + this.id].stopBlast();
  61.             this.endMessageSent = true;
  62.             this.startClip.segment.gotoAndStop("endCap");
  63.          }
  64.          removeMovieClip(this.clip["blasterALaserSeg" + (this.c - this.l) + "Clip" + this.id]);
  65.          this.startClip._x += this.xInc;
  66.       }
  67.       if(_root["blasterA" + this.id].f2 == "blasting")
  68.       {
  69.          this.clip._x = this.dir != "L" ? _root["blasterA" + this.id].x + 39 : _root["blasterA" + this.id].x;
  70.          this.clip._y = _root["blasterA" + this.id].y;
  71.       }
  72.       if(this.clip.hitTest(_root[_root.char + "Clip"]))
  73.       {
  74.          _root[_root.char].hit(this.xInc / 2,0,100,this.power);
  75.       }
  76.       if(this.c > 3 && Math.abs(this.endClip._x - this.startClip._x) < 100)
  77.       {
  78.          _root.removeEnemyShot("blasterALaser" + this.id);
  79.       }
  80.    }
  81. }
  82.